package com.wzy.level.detail.detailServlet;

import com.wzy.Jdbc封装.pojo.News_detail;
import com.wzy.level.detail.detailService.detailService;
import com.wzy.level.detail.detailServiceImpl.detailServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet("/insert_updateServlet")
public class insert_updateServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
//        req.setCharacterEncoding("utf-8");
//        resp.setCharacterEncoding("utf-8");
        int id = Integer.parseInt(req.getParameter("id"));
        int state = Integer.parseInt(req.getParameter("state"));

        detailService detail = new detailServiceImpl();
        News_detail detail1 = detail.selectById(id);
        HttpSession session = req.getSession();
        session.setAttribute("detail",detail1);
        session.setAttribute("state",state);

        PrintWriter writer = resp.getWriter();
        writer.println(1);
        writer.flush();
        writer.close();

//        req.getRequestDispatcher("/system/detail_form.jsp").forward(req,resp);
    }
}
